//
//  HowToViewController.m
//  123
//
//  Created by Wang on 14/11/19.
//  Copyright (c) 2014年 Wang. All rights reserved.
//

#import "HowToViewController.h"
#import "HowToModel.h"
#import "HowToCell.h"
@interface HowToViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, retain) UIScrollView *scroll;
@end

@implementation HowToViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    [self.navigationItem setTitle:@"怎么搭"];
    [self.navigationController.navigationBar setTranslucent:NO];
    [self creatScrollView];
    [self creatTableView];
    [self creatButton];
}

- (void)creatScrollView
{
    self.scroll = [[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height / 6)] autorelease];
    [_scroll setBackgroundColor:[UIColor orangeColor]];
    [_scroll setContentSize:CGSizeMake(_scroll.frame.size.width * 2, 0)];
    [self.view addSubview:_scroll];
}

- (void)creatButton
{
    for (int i = 0; i < 3; i ++) {
        UIButton *button = [[[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width / 6 + i * (_scroll.frame.size.width / 6 + 30), _scroll.frame.size.height / 3, _scroll.frame.size.width / 8, _scroll.frame.size.height / 3)] autorelease];
        [button setTag:1000 + i];
        NSMutableArray *arr = [NSMutableArray arrayWithObjects:[UIColor yellowColor], [UIColor redColor], [UIColor blueColor], nil];
        
        [button setBackgroundColor:[arr objectAtIndex:i]];
        [button.layer setCornerRadius:20];
        [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
        [_scroll addSubview:button];
    }
}

- (void)buttonClick:(id)sender
{
    UIButton *but = (UIButton *)[self.view viewWithTag:1000];
    
}

- (void)creatTableView
{
    UITableView *table = [[UITableView alloc] initWithFrame:CGRectMake(0, _scroll.frame.size.height + 10, self.view.frame.size.width, self.view.frame.size.height / 6 * 5) style:UITableViewStylePlain];
    table.delegate = self;
    table.dataSource = self;
    [table registerClass:[HowToCell class] forCellReuseIdentifier:@"cellPool"];
    [self.view addSubview:table];
    [table release];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 150;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    HowToCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellPool"];
    return cell;
}




@end
